package org.hot100_2;

public class leetcode141 {
    public boolean hasCycle(ListNode head){

        if (head==null || head.next==null){
            return false;
        }

        ListNode slow = head;
        ListNode fast = head.next;

        while (fast!=slow){

            if ( fast==null || fast.next==null){
                return false;
            }
            //慢指针走一步、快指针走两步
            slow=slow.next;
            fast=fast.next.next;
        }


        return true;
    }
}
